package appconfig

import (
	"github.com/spf13/viper"
	"github.com/zeromicro/go-zero/core/logx"
)

type AppConfig struct {
	Mysql
	Redis
	ElasticSearch
	Alipay
}

type Mysql struct {
	Host     string
	Port     int
	User     string
	Password string
	Database string
}

type Redis struct {
	Host     string
	Port     int
	Password string
}

type ElasticSearch struct {
	Host string
	Port int
}

type Alipay struct {
	AppId      string
	PrivateKey string
	NotifyURL  string
	ReturnURL  string
}

var AppCfg AppConfig

func Init() {
	viper.SetConfigFile("./appconfig/dev.yaml")
	viper.ReadInConfig()
	viper.Unmarshal(&AppCfg)

	logx.Info("appconfig init success: ", AppCfg)
}
